package gupao.concurrency.demo.risk.scru.processor;

import gupao.concurrency.demo.risk.exct.ExctResult;
import gupao.concurrency.demo.risk.scru.ScruResult;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

@Slf4j
public class ScruProcessor {

    public static ScruResult process(ExctResult lastResult){
        log.info("process scru..");
        ScruResult result = overrideEdcs(lastResult);
        prepareParams(result);
        result.setJob(lastResult.getJob());
        return result;
    }

    private static ScruResult overrideEdcs(ExctResult edcsResult){
        List<Double> edcList = edcsResult.getEdcDataList().stream().filter(d -> d > 0).collect(Collectors.toList());
        List<Double> edsList = edcsResult.getEdsDataList().stream().filter(d -> d > 0).collect(Collectors.toList());
        ScruResult result = new ScruResult();
        result.setOverrideEdcList(edcList);
        result.setOverrideEdsList(edsList);
        return result;
    }

    private static void prepareParams(ScruResult result){
        result.setParamMap(new HashMap<>());//mock empty params
    }
}
